<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<script type="text/javascript">
 function subModulus(){
	var json = "{'airMailPriceKindId':'"+${airMailPriceKindId}+"','channelNumber':'"+${channelNumber}+"','recode':[";
 	var ids =  $("#modulusTbody").find("tr");
 	var flag =  true;
	$.each(ids,function(i){
		var a = $("#"+this.id+"_mo").val();
		var b = $("#"+this.id+"_ramo").val();
		var c = $("#"+this.id+"_dc").val();
		var d = $("#"+this.id+"_of").val();
		if(a==null || b==null || c==null || d==null || ""==$.trim(a)|| ""==$.trim(b)|| ""==$.trim(c)|| ""==$.trim(d)){
			flag = false;
		}
		if(i==0){
			json+= "{'id':'"+this.id+"','mo':'"+$("#"+this.id+"_mo").val()+"','ramo':'"+$("#"+this.id+"_ramo").val()+"','dc':'"+$("#"+this.id+"_dc").val()+"','of':'"+$("#"+this.id+"_of").val()+"'}";
		}else{
			json+= ",{'id':'"+this.id+"','mo':'"+$("#"+this.id+"_mo").val()+"','ramo':'"+$("#"+this.id+"_ramo").val()+"','dc':'"+$("#"+this.id+"_dc").val()+"','of':'"+$("#"+this.id+"_of").val()+"'}";
		}
	});
	json += "]}";
	//alert(${channelNumber});
	$("#kvmotest").val(json);
	if(!flag){
		alertMsg.warn('数据不可以为空！');
	}else{
		var bp = '<%=basePath%>updateAirMailChannelModulus';
		$.post(bp,{"moJson":json},function(msg){
			alertMsg.correct("提交成功！");
		});
		$.pdialog.closeCurrent();		
	}
 } 
</script>
<!-- 小包客户价格类型所含渠道系数折扣设置 -->
<div class="pageContent">
	<div class="pageFormContent" layoutH="56">	
		<table class="table" width="100%">
			<thead>
				<tr>
					<th>序号</th>
					<th>所属分类</th>
					<th>渠道名称</th>
					<th>挂号费(公布价)</th>
					<th>开始区</th>
					<th>目的区</th>
					<th>公布价系数公式</th>
					<th>挂号费系数公式</th>
					<th>折扣设置</th>
					<th>操作费用</th>
				</tr>
			</thead>
			<tbody id="modulusTbody">
				<s:iterator value="airMailPriceModulusList" var="mo" status="idx">
					<tr id ="<s:property value="#mo[12]"/>">
						<td><s:property value="#idx.count"/></td>
						<td><s:property value="#mo[0]"/></td>
						<td><s:property value="#mo[7]"/></td>
						<td><s:property value="#mo[8]"/></td>
						<td><s:property value="#mo[1]"/></td>
						<td><s:property value="#mo[2]"/></td>
						<td><input id="<s:property value="#mo[12]"/>_mo" type="text" size="6" class="required" value="<s:property value="#mo[13]"/>" /></td><!-- 公布价系数 -->
						<td><input id="<s:property value="#mo[12]"/>_ramo" type="text" size="6" class="required" value="<s:property value="#mo[14]"/>" /></td><!-- 挂号费系数 -->
						<td><input id="<s:property value="#mo[12]"/>_dc" type="text" size="6" class="required" value="<s:property value="#mo[15]"/>" /></td><!-- 折扣 -->
						<td><input id="<s:property value="#mo[12]"/>_of" type="text" size="6" class="required" value="<s:property value="#mo[16]"/>" /></td><!-- 操作费用 -->
					</tr>
				</s:iterator>
			</tbody>
		</table>
	</div>	
	<div class="formBar">
		<ul>
			<li><div class="buttonActive"><div class="buttonContent"><button onclick="subModulus();">提交</button></div></div></li>
			<li><div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div></li>
		</ul>
	</div>
</div>
